<?php
/* SVN FILE: $Id: course.php 12 2009-09-26 20:39:20Z kenreily@gmail.com $ */
/**
 * Short description for file.
 *
 * Long description for file
 *
 * PHP versions 4 and 5
 *
 * Recenseo: Online submission and reviewing for education
 * Copyright 2008-2009, Ken Reily
 *
 * Licensed under The MIT License
 * Redistributions of files must retain the above copyright notice.
 *
 * $Date: 2009-09-26 20:39:20 +0000 (Sat, 26 Sep 2009) $
 * $Revision: 12 $
 * $Author: kenreily@gmail.com $
 * $HeadURL: http://recenseo.googlecode.com/svn/trunk/app/models/course.php $
 */
class Course extends AppModel {
  var $name = 'Course';
  var $hasMany = 'Assignment';
  var $hasAndBelongsToMany = 'User';
  
  function listForUser($user_id)
  {
    return $this->query("SELECT id,name,term " .
                          "FROM courses JOIN courses_users ON course_id = id " .
                         "WHERE user_id = {$user_id} " .
                      "ORDER BY begin_date DESC "); 
  }
  
  function nameForId($id)
  {
    return $this->query("SELECT name FROM courses AS c WHERE id = {$id}");
  } 
}
?>